$(function(){
	$('#dlg').dialog("close");
	$("#dg").edatagrid({
		url : frame.fullUrl('/smdc/div/page.json'),
		onDblClickRow : double_row_click
	});
	
	frame.secSelect($('#update_param > #secId'),{
		width:150
	});
	frame.secSelect($('#search_secId'));
});

function click_search() {
	var param = $("#search_param").form("getData");
	$('#dg').datagrid('load',param);
}

function double_row_click(index, row){
	$('#ff').form("clear");
	$('#ff').form("load",row);
	$('#dlg').dialog("open");
}

function click_open_update() {
	$("#update_dialog").dialog("open");
}

function click_update() {
	var data = $("#update_param").form("getData");
	$.ajax(frame.fullUrl('/smdc/div/update.json'), {data:data, mask:true});
}

function click_update_all() {
	$.ajax(frame.fullUrl('/smdc/div/update.json'), {mask:true});
}

function click_open_upload(){
	$.upload({
		action : frame.fullUrl('/smdc/div/datayesupload.json'), //上传地址
		fileName : "file",    //文件名称。用于后台接收
		accept : ".xlsx,.xls,.csv" //文件类型
	});
}

function dlg_click_save(){
	$('#ff').form('ajaxSubmit',{ 
		url: frame.fullUrl('/smdc/div/save.json'),
		success: function(data){
			if(data.sucesse==true){
				dlg_click_cancle();
				click_search();
			}
		}
	});
}

function dlg_click_delete() {
	$.messager.confirm('确认', '您确认想要删除吗？', function(r) {
		if (!r) {
			return;
		}
		$('#ff').form('ajaxSubmit',{ 
			url: frame.fullUrl('/smdc/div/delete.json'),
			success:  function(data) {
				if (data.sucesse) {
					$('#dlg').dialog("close");
					click_search();
				}
			} 
		});
	});
}

function dlg_click_cancle(){
	$('#dlg').dialog("close");
}


